package service.Impl;
import dao.Impl.UserLoginDaoImpl;
import dao.Impl.addUserDaoImpl;
import dao.InsertUsers;
import dao.UserLoginDao;
import exception.UserNotFoundException;
import pojo.User;
import service.UserLoginService;

public class UserLoginServiceImpl implements UserLoginService {
    @Override
    public User userlogin(String username, String userpwd) {
        UserLoginDao userLoginDao=new UserLoginDaoImpl();
        User user = userLoginDao.SelectByUsernameAndUserpwd(username,userpwd);
        if(user ==null){
            throw  new UserNotFoundException("用户名或密码有误");
        }
        return user;
    }

    @Override
    public void addUser(User user) {
        InsertUsers insertUsers=new addUserDaoImpl();
        insertUsers.addUser(user);
    }
}
